package com.example.commen.base

import android.content.Context
import android.view.View
import com.example.zhouwei.library.CustomPopWindow


/**
 * @author zyju
 * @date 2024/3/14 14:32
 * @see https://github.com/pinguo-zhouwei/CustomPopwindow
 */
abstract class BasePopupWindow() {
    private lateinit var pop: CustomPopWindow
    lateinit var context: Context
    private fun build(context: Context, dropView: View): CustomPopWindow {
        this.context = context
        val view = getlayoutView()
        InitView()
        //创建并显示popWindow
        pop = CustomPopWindow.PopupWindowBuilder(context)
            .setView(view)
            .setOutsideTouchable(true)//是否PopupWindow 以外触摸dissmiss
            .create()
            .showAsDropDown(dropView, 0, 20)
        return pop
    }

    fun dissmiss() {
        pop.dissmiss()
    }

    fun BuildAndShow(context: Context, dropView: View) {
        build(context, dropView)
    }

    abstract fun getlayoutView(): View
    abstract fun InitView()
}